package com.gyg.controller;

import com.gyg.client.CloudDocumentClient;
import com.gyg.domain.CloudUser;
import com.gyg.enums.SessionEnum;
import com.gyg.returns.RespEntity;
import com.gyg.returns.RespTable;
import com.gyg.utils.OSSUtil;
import com.gyg.vo.param.BanParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RestController
@Api(value = "文档模块", tags = "文档模块")
@RequestMapping("/cloud-document")
public class CloudDocumentController {

    @Resource
    private OSSUtil ossUtil;

    @Resource
    private CloudDocumentClient cloudDocumentClient;

    @ApiOperation(value = "文档列表")
    @GetMapping("/list")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "page", value = "当前页数", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "limit", value = "每页数量", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "ban", value = "封禁标识", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "String", name = "username", value = "用户账号", required = true),
    })
    public RespTable cloudDocumentList(@RequestParam(value = "page", required = true) Integer page,
                                       @RequestParam(value = "limit", required = true) Integer limit,
                                       @RequestParam(value = "ban", required = true) Integer ban,
                                       @RequestParam(value = "username", required = false) String username) {
        RespTable respTable = cloudDocumentClient.cloudDocumentList(page, limit, ban, username);
        return respTable;
    }

    @PutMapping("/ban")
    @ApiOperation(value = "封禁文档")
    public RespEntity banDocument(BanParam banParam) {
        RespEntity respEntity = cloudDocumentClient.banDocument(banParam);
        return respEntity;
    }

    @PutMapping("/unseal")
    @ApiOperation(value = "解封文档")
    public RespEntity unsealDocument(BanParam banParam) {
        RespEntity respEntity = cloudDocumentClient.unsealDocument(banParam);
        return respEntity;
    }

}
